<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
	<title></title>
	<link href="css/mui.min.css" rel="stylesheet" />
	<link href="css/detail.css" rel="stylesheet" />
</head>
<body>
	<header class="mui-bar mui-bar-nav" >
		<p class=" mui-pull-left" id="back"><a href="javascript:history.go(-1)">返回</a></p>
		<h1 class="mui-title">详细信息</h1>
	</header>
	<div class="mui-content">
		<div class="mui-content-padded">
			<p>姓名：<span id="per">fdsafds</span></p>
			<p>部门：<span id="dept"></span></p>
			<p>联系方式：<span id="mobile"></span></p>
		</div>		
	</div>
</body>
	<script src="js/mui.min.js"></script>
	<script src="js/app.js"></script>
<script>
	var per = document.getElementById("per");
	var dept = document.getElementById("dept");
	var mobile = document.getElementById("mobile");
	var url = decodeURI(decodeURI(window.location.href));
	var urlArr=url.split("?");
	var info = urlArr[urlArr.length-1];
	var infoARrr = info.split("&");
	var id = infoARrr[0].split("=")[1];
	var deptId = infoARrr[1].split("=")[1];
	
	//创建xhr对象
	function getXMLHttpRequest() {  
	    var xhr;  
	    try {  
	        xhr = new XMLHttpRequest();  
	    } catch (err1) {  
	        try {  
	            xhr = new ActiveXObject("Microsoft.XMLHTTP");  
	        } catch (err2) {  
	            alert("您的浏览器版本不支持Ajax....");  
	        }  
	    }  
	    return xhr;  
	}
	//获取empl.json 数据
	function saxJson() {
	    var xhr = getXMLHttpRequest();  
	    var deptId="";
	    xhr.open("GET", "API/Data/empl.json", true);  
	    xhr.send();  
	    xhr.onreadystatechange = function() {  
	        if (xhr.readyState == 4 && xhr.status == 200) {
	        	var i=0;
	        	var Empls = eval("(" + xhr.responseText + ")").Empls;
	        	var len = Empls.length;
				for(;i<len;i++){
					if(String(id)==Empls[i].ID){
						per.innerHTML = Empls[i].Name;
						mobile.innerHTML=Empls[i].Mobile;
						return;
					}
				}
	        }  
	    }
	} 
	//获取dept.json 数据
	function deJson(){
		var xhr1 = getXMLHttpRequest();  
	    xhr1.open("GET", "API/Data/dept.json", true);  
	    xhr1.send();  
	    xhr1.onreadystatechange = function() {  
	        if (xhr1.readyState == 4 && xhr1.status == 200) {
	        	var j=0;
	        	var Depts = eval("(" + xhr1.responseText + ")").Depts;
	        	var de_len = Depts.length;
				for(;j<de_len;j++){
					if(String(deptId)==Depts[j].ID){
						dept.innerHTML = Depts[j].Title;
						return;
					}
				}
	        }  
	    }
	}
	saxJson();
	deJson();
	mui.init();
	mui.plusReady(function() {
		mui.back = function(event) {
			window.history.go(-1);
		};
	});
</script>
</html>